package com.digitalart.futbol.hibernate.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.digitalart.futbol.hibernate.dao.CantonDao;
import com.digitalart.futbol.hibernate.ejb.Canton;
import com.digitalart.futbol.hibernate.service.CantonService;

@Service
public class CantonServiceImpl implements CantonService {

	@Autowired(required=true)
	private CantonDao cantonDao;
	
	
	@Transactional
	public Canton retriveCanton(int id) {
		Canton result = this.cantonDao.findById(id);
		return result;
	}

	@Transactional
	public Canton createCanton(Canton canton) {
		Canton result = this.cantonDao.persistOnMerge(canton);
		return result;
	}

	@Transactional
	public List<Canton> findByProvincia(int id) {
		List<Canton> result = this.cantonDao.findByProvincia(id);
		return result;
	}

	@Transactional
	public List<Canton> findAll() {
		List<Canton> result = this.cantonDao.findAll();
		return result;
	}

}
